// pages/customizeActivity/myCustomize/customizeDetails/customizeDetails.js
var util = require('../../../../utils/util.js');
var wxcache = require('../../../../utils/wxcache.js');
var api = require('../../../../config/api.js');
var user = require('../../../../services/user.js');

var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    customizeLists:null,
    iconProcessLists: null,
    ageGroup: null,
    menWomenNumList: null,
    typeList:null,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    var that = this;
    if(!options.id){
      return
    }

    util.request(api.detailEnterpriseCustomization+"/"+options.id).then(res => {

      if (res.code == 200) {

          var process  = res.responseBody.customizationProcessList
          if (process) {
            for (var index = 0; index < process.length; index++) {

              if (process[index].selected) {
                process[index].lineShow = true
              } else {
                process[index].lineShow = false
                if (index >= 1) {
                  process[index - 1].lineShow = false
                }
              }
            }
          }

        console.log(res)
        that.setData({
          customizeLists: res.responseBody,
          ageGroup:res.responseBody.ageGroup,
          iconProcessLists: process,
          menWomenNumList: res.responseBody.menWomenNumList,
          typeList:res.responseBody.typeList
        })
      }
    })
  },
  toDesign:function(){

    var url = this.data.customizeLists.campaignUrl;

    if(url){
      wx.navigateTo({
        url: '/pages/customizeActivity/myCustomize/customizeDetails/designPlan/designPlan?campaignUrl=' + this.data.customizeLists.campaignUrl,
      })
    }else{
      wx.showToast({
        title: '方案还在准备中喔~',
        duration: 1500,
        icon: 'none',
        mask: true
      })
    }
      
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})